import {defineStore} from "pinia";

export const useUserStore = defineStore('user', {
    persist: true,
    state: () => {
        return {
            userInfo: {
                id: undefined,
                username: undefined,
                avatar: 'https://zzjtpp.top/blogAPI/uploadFile/%E5%A4%B4%E5%83%8F.bmp',
                status:undefined,
            },
            token:'',
            refreshToken:'',
        }
    },
    getters: {
        id: (state): any => {
            return state.userInfo?.id
        },
        username: (state): any => {
            return state.userInfo?.username
        },
        avatar: (state): any => {
            return state.userInfo?.avatar
        },
    },
    actions: {
        setUserInfo(params:any) {
            this.userInfo=params
        },
        setToken(params:any){
            this.token=params
        },
        setRefreshToken(params:any){
            this.refreshToken=params
        }
    }
})
